<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Identi Engine Documentation - User Generated Content</title>

<link rel="stylesheet" href="../css/site.css" type="text/css" media="all" />
<link rel="stylesheet" href="../css/documentation.css" type="text/css" media="all" />
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print" />
<link rel="shortcut icon" href="../images/logo16.png"/>

<script language="javascript" type="text/javascript" src="../ident/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript" src="../ident/ident-0.1.js"></script>


<script language="javascript" type="text/javascript">

     /*
     *  Copyright 2009, Glenn Jones
     *  Licensed under the MIT license.
     *  http://identengine.com/license/
     *  More information: http://identengine.com/
     */
    
    
    // Page functions///
    // -------------------------------------------------


    jQuery(document).ready(function () {
         buildList('Library data', ident._endPoints);     
    });  
    
           var contentTypes = new Array();
        var schemaTypes = new Array();
        
     function buildList(header, json){   
        
        jQuery('#results1').html('');
        jQuery('#results2').html('');
        

        
        var mappingcount = 0;
        for(var x = 0; x <= json.sites.length-1; x++){
            mappingcount += json.sites[x].urlmappings.length;
            
        }
       
        var half = Math.round(json.sites.length / 2);
        var ul1 = jQuery('<ul></ul>').appendTo('#domains1'); 
        var ul2 = jQuery('<ul></ul>').appendTo('#domains2');
        
        for(var x = 0; x <= json.sites.length-1; x++){
            if(x >= half)
                var li = jQuery('<li>' + json.sites[x].domain +  '</li>').appendTo(ul2);
            else
                var li = jQuery('<li>' + json.sites[x].domain +  '</li>').appendTo(ul1);
            
            if(json.sites[x].urlmappings){
                if(json.sites[x].urlmappings.length){
                   for(var i = 0; i <= json.sites[x].urlmappings.length-1; i++){
                        appendContentTypes(json.sites[x].urlmappings[i].contenttype)
                        appendSchemaTypes(json.sites[x].urlmappings[i].schema)
                    }
                }
            }  
        }
        
        contentTypes.sort();
        schemaTypes.sort();
        
        var ul3 = jQuery('<ul></ul>').appendTo('#contenttypes'); 
        var ul4 = jQuery('<ul></ul>').appendTo('#schemas');
        
        for(var x = 0; x <= contentTypes.length-1; x++){
            var li = jQuery('<li>' + contentTypes[x]+  '</li>').appendTo(ul3);
        }
        
        for(var x = 0; x <= schemaTypes.length-1; x++){
            var li = jQuery('<li>' + schemaTypes[x]+  '</li>').appendTo(ul4);
        }
     }
     
     function appendContentTypes(type){
        found = false;
        for(var x = 0; x <= contentTypes.length-1; x++){
            if(type == contentTypes[x]){
                found = true;
                break;
            }    
        }
        if(!found)
            contentTypes[contentTypes.length] = type;
     }
     
     function appendSchemaTypes(type){
        found = false;
        for(var x = 0; x <= schemaTypes.length-1; x++){
            if(type == schemaTypes[x]){
                found = true;
                break;
            }    
        }
        if(!found)
            schemaTypes[schemaTypes.length] = type;
     }
    
</script>

<link type="application/rss+xml" rel="alternate" title="Ident Engine (RSS)" href="http://identengine.com/Blog/syndication.axd?format=rss" />
<link type="application/atom+xml" rel="alternate" title="Ident Engine (ATOM)" href="http://identengine.com/Blog/syndication.axd?format=atom" />

</head>

<body>
<div class="header">
		<div class="centered">
			<a href="http://identengine.com/"><h1><span>Ident Engine</span></h1></a>
			<h2 id="strapline"><span>A JavaScript library that retrieves and aggregates profiles from across the web</span> </h2>
		</div>
	</div>

	<div class="content">
		<div class="centered">
		<div class="floatclear" style="clear:both">
			<ul class="menu">
				<li><a href="../index.htm" class="firstItem">home</a></li>
				<li><a href="index.htm">documentation</a></li>
				<li><a href="../opentables/index.htm">api</a></li>
				<li><a href="http://identengine.com/blog/">blog</a></li>
				<li><a href="../about/index.htm" class="lastItem">about</a></li>
			</ul>
		</div>	

	
		<h1>Documentation - User Generated Content</h1>
		
		<p class="title-expansion">How to retrieve user generated content from public APIs and feeds.</p>
		
		
		<p>The Identi Engine has the ability to retrieve different types of user 
		generated content. This content is stored in a number of collections ident.entries, 
		ident.events and ident.tags. See demo <a href="../../lifestream.htm">Lifestream</a> </p>
		<p>There are two ways to extract user generated content from the 
		API endpoints discovered by Identi. The findContent method can only be 
		used after a search, whilst the loadContent works independently of the search. </p>
		<h2>&nbsp;Option A - Using a search to discover content endpoints </h2>
		
<pre> var doc = jQuery(document);

    doc.ready(function () {
    ident.useInwardEdges = true
    doc.bind('ident:update', loadContent);

    ident.search(&#39;http://twitter.com/glennjones&#39;);
 });</pre>
		<p> 
		The code snippet above is using jQuery to create a function which 
		executes as soon as the HTML document is loaded. 
		</p>
		
		<h3>Properties</h3>
		    <dl>
				<dt>useInwardEdges</dt>
                <dd>The useInwardEdges property controls how the identities are found. If it is 
		set to true it will return a larger sets of results, but there is a 
		greater chance that Identi Engine will return the wrong information about an 
		individual. There will be less of a chance of error if the property is 
		set to false. By default this 
		property is set&nbsp; to true.</dd>
		                            
            </dl>
		
		<h3>Binding the rendering function</h3>
		
		<p>The Identi Engine will update the identities collection a number of 
		times during a single search. To capture the updates we need to bind our 
		own rendering function to the events fired by the library. 
		This can be done easily with jQuery for example:</p>
		<pre> doc.bind(&#39;ident:update&#39;, loadContent);</pre>
		<p> Once you have found an individual&#39;s accounts using the search you can 
		use the findContent function to retrieve content. Any content found 
		by Identi will be stored in the content collections. It will only load 
		content where the search has identified a valid account for the requested 
		domain.</p>
		<pre id="line16">function loadContent(){ 
   ident.findContent(&#39;twitter.com&#39;, &#39;Status&#39;, &#39;hAtom&#39; );
   ident.findContent(&#39;identi.ca&#39;, &#39;Status&#39;, &#39;hAtom&#39; );  
   ident.findContent(&#39;flickr.com&#39;, &#39;Images&#39;, &#39;Atom&#39; ); 
   ident.findContent(&#39;del.icio.us&#39;, &#39;Bookmarks&#39;, &#39;Rss&#39;); 
   ident.findContent(&#39;upcoming.yahoo.com&#39;, &#39;Events&#39;, &#39;Rss&#39; );
   ident.findContent(&#39;last.fm&#39;, &#39;Activity&#39;, &#39;Rss&#39; );
   ident.findContent(&#39;ffffound.com&#39;, &#39;Images&#39;, &#39;Rss&#39; );
   ident.findContent(&#39;tumblr.com&#39;, &#39;Lifestream&#39;, &#39;Rss&#39; );
   ident.findContent(&#39;backtype.com&#39;, &#39;Activity&#39;, &#39;Rss&#39; );
   ident.findContent(&#39;vimeo.com&#39;, &#39;Video&#39;, &#39;Rss&#39; );
}</pre>
		
		<h2>Option B - Direct call to collect content</h2>
		
		<pre>ident.loadContent( 
  &#39;http://identi.ca/glennjones&#39;, 
  &#39;identi.ca&#39;, 
  &#39;Identica&#39;, 
  &#39;Status&#39;, 
  &#39;hAtom&#39; 
);</pre>

	
		<p>The loadContent function is straight forward. You need to know a 
		valid account, the content schema and type that are available before 
		making the request.&nbsp; </p>
		<h2>Rendering the content collection</h2>
		<pre id="line17">ident.entries.sort(ident.sortByDate);
for (var i = 0; i &lt; ident.entries.length; i++) {
   jQuery(&#39;&lt;div&gt;&#39; + ident.entries[i][&#39;entry-title&#39;] + &#39;&lt;/div&gt;&#39;).appendTo( div );
   ...

}</pre>
		<p>To render the content you need to loop around the collection and 
		retrieve the properties. Each collection has a different set of 
		properties. Please refer to the data structures of each collection; 
		<a href="identities-structure.htm">Identity</a>, 
<a href="profile-structure.htm">Profile</a>, 
<a href="resume-structure.htm">Resume</a>, 
<a href="entry-structure.htm">Entry</a>, 
<a href="event-structure.htm">Event</a> and 
<a href="tag-structure.htm">Tag</a>.</p>
		<h2>The files that need to be included in the page</h2>
		<p>There are five files you must include in your HTML for the Identi Engine to 
		retrieve user content. </p>
		<pre>
jquery-1.3.2.min.js
ident-0.1.js
ident-profile-0.1.js
ident-content-0.1.js
ident-yql-parser-0.1.js</pre>
		<p>Alternatively, you can swap the parser to UfXtract which in some 
		cases will return more results. The UfXtract parser should only be 
		used for low traffic situations.</p>
		<pre>
query-1.3.2.min.js
ident-0.1.js
ident-profile-0.1.js
ident-content-0.1.js
ident-yql-parser-0.1.js
ident-ufxtract-parser-0.1.js
</pre>
		<p>&nbsp;</p>
		
		<p>To find which combination of domain, content-type and schema are supported please use the <a href="../debug/debug-mappings.htm">debug mapping tool</a>.</p>
		
		<h2>Supported domains</h2>
		<div class="floatclear">
		    <div id="domains1"></div>
            <div id="domains2"></div>
        </div>
        
        <h2>Supported content types</h2>
		<div id="contenttypes"></div>
		
		<h2>Supported schemas</h2>
		<div id="schemas"></div>
		
		</div>
		</div>
		
		
   <div class="footer">
		<div class="centered">
			<p class="cc-license">
				<a rel="license" href="http://creativecommons.org/licenses/by/2.0/uk/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/2.0/uk/80x15.png" /></a><br /><span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" property="dc:title" rel="dc:type">Identi Engine Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.glennjones.net/" property="cc:attributionName" rel="cc:attributionURL">Glenn Jones</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/2.0/uk/">Creative Commons Attribution 2.0 UK: England &amp; Wales License</a>.<br />Based on a work at <a xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://identengine.com/" rel="dc:source">identengine.com</a>.
			</p>
			<p class="copyright">© Copyright Glenn Jones 2009. All Rights Reserved.</p>
		</div>
	</div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3021774-6");
pageTracker._trackPageview();
} catch(err) {}</script>
	

</body>
</html>
